var dtGridColumns = [
    {
        id: 'id',
        title: 'ID',
        type: 'integer',
        columnClass: 'text-center',
        headerStyle: 'color:grey; white-space:nowrap;'
    }, {
        id: 'ownerName',
        title: '机主名称',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey; white-space:nowrap;'
    }, {
        id: 'identityNum',
        title: '机主身份证号',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;'
    }, {
        id: 'emissionRegistration',
        title: '排放登记',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey; white-space:nowrap;'
    }, {
        id: 'deviceID',
        title: '设备编号',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;'
    }, {
        id: 'brands',
        title: '机械品牌',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;'
    }, {
        id: 'colour',
        title: '机械颜色',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;',
        hideType: 'xs|sm|md|lg'
    }, {
        id: 'type',
        title: '机械类型',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey; white-space:nowrap;'
    }, {
        id: 'country',
        title: '生产国别',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey; white-space:nowrap;'
    }, {
        id: 'bigShelfNum',
        title: '大架子号',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey; white-space:nowrap;'
    }, {
        id: 'fuel',
        title: '燃油类型',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;'
    }, {
        id: 'enginePlateNum',
        title: '发动机铭牌号',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;'
    }, {
        id: 'machineQuality',
        title: '整机质量',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;',
        hideType: 'xs|sm|md|lg'
    }, {
        id: 'dateOfProduction',
        title: '出厂日期',
        type: 'date',
        format: 'yyyy-MM-dd',
        otype: 'time_stamp_ms',
        oformat: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;',
        hideType: 'xs|sm|md|lg'
    }, {
        id: 'nuclearLoadingQuality',
        title: '核载质量',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;'
    }, {
        id: 'buyDate',
        title: '购买时间',
        type: 'date',
        format: 'yyyy-MM-dd',
        otype: 'time_stamp_ms',
        oformat: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;',
        hideType: 'xs|sm|md|lg'
    }, {
        id: 'plateNum',
        title: '铭牌号',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;'
    }, {
        id: 'hydraulicPlateNum',
        title: '液压泵铭牌',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;',
        hideType: 'xs|sm|md|lg'
    }, {
        id: 'remark',
        title: '备注信息',
        type: 'string',
        columnClass: 'text-center',
        headerStyle: 'color:grey;',
        hideType: 'xs|sm|md|lg'
    }, {
        id: 'operation',
        title: '操作',
        type: 'string',
        columnClass: 'text-center tpl-table-black-operation',
        headerStyle: 'color:grey; white-space:nowrap; padding: 0px 60px;',
        resolution: function (value, record, column, grid, dataNo, columnNo) { //此处的值（value）不直接显示
            var content = '';
            content += '<a href="#" onclick="loadPage(\'machineryInfo/' + record.id + '/select\');"> <i class="am-icon-pencil"></i>编辑</a> ' +
                '<a href="#" onclick="loadPage(\'machineryInfo/' + record.id + '/printPreview\');"> <i class="am-icon-pencil"></i>预览/打印</a> ';
            return content;
        }
    }];

var dtGridOption = {
    lang: 'zh-cn',
    ajaxLoad: true,
    check: true,
    checkWidth: '37px',
    loadURL: 'machineryInfo/list',
    columns: dtGridColumns,
    gridContainer: 'dtGridContainer',
    toolbarContainer: 'dtGridToolBarContainer',
    tools: '',
    pageSize: 10, //默认每页十条记录
    pageSizeLimit: [10, 20, 30] //分页选项：每页10、20\或者30条记录
};
var grid = $.fn.dlshouwen.grid.init(dtGridOption);


$(function () {
    grid.load();
    $('select').selected();
});

function search() {
    grid.parameters = new Object();
    grid.parameters['title'] = $("#title").val();
    grid.refresh(true);
}

function delteAll() {
    var checkId = getCheckAll(grid.getCheckedRecords());
    if (checkId != '') {
        del("machineryInfo/" + checkId + "/deleteBatch", search);
    } else {
        layer.msg('请选择要删除的数据', {
            icon: 3
        });
    }
}

